// 创建 start-playwright-mcp.js
const { spawn } = require('child_process');
const path = require('path');

console.log('Starting Playwright MCP with config...');

const configPath = path.join(__dirname, 'playwright-mcp-config.json');

const mcp = spawn('npx', [
    '@playwright/mcp',
    '--host', '0.0.0.0',
    '--port', '8931',
    '--config', configPath,
    '--no-sandbox'
], {
    stdio: 'inherit'
});

mcp.on('close', (code) => {
    console.log(`Playwright MCP exited with code ${code}`);
});

mcp.on('error', (err) => {
    console.error('Failed to start Playwright MCP:', err);
});

console.log(`Config file: ${configPath}`);
console.log('Playwright MCP will be available at: http://localhost:8931');